const { User } = require('../model')

class UserController {
  async login(ctx, next) {
    const { username, password } = ctx.request.body
    const result = await User.find({ username, password })
    console.log('登录查询结果：', result)
    let res = {
      flag: true,
      msg: '登录成功！',
      data: ''
    }
    if (result.length > 0) {
      ctx.body = res
    } else {
      res.msg = '查无此人~'
      res.flag = false
      ctx.body = res
    }
  }
}

module.exports = new UserController()